#ifndef DATAPRE_H
#define DATAPRE_H
#include<iostream>
#include<common.h>
#include<vector>
#include "dbconnector.h"


struct Member{
    std::string id;
    std::string name;
    bool enable;
};


class MemberManage{
private:
    std::vector<Member> members;
    //TODO delete ,implement it later
    bool deleteMember();
public:
    MemberManage();
    ~MemberManage();
    std::string toJson();
    Member getMember(const int & i);
    int count();
    bool addMember(const std::string & id,const std::string & name);
    bool editMember(const int & index,const std::string & id ,const std::string & name);
    bool initFromJsonString(const std::string & json);
    std::string getNewId();

};


enum DAY{
    MORNING=1,
    AFTER=2,
    ALL=3
};

struct OneLeave{
    std::string m_id ;
    std::string m_name;
    std::string reason;
    int time;
    OneLeave operator=(const OneLeave& leave)const {
        OneLeave temp;
        temp.m_id = leave.m_id;
        temp.m_name = leave.m_name;
        temp.time = leave.time;
        return temp;
    }
    bool operator==(const OneLeave& leave) const{
        if(m_id == leave.m_id&&
                m_name == leave.m_name&&
                time == leave.time){
            return true;
        }
        return false;;
    }
};

class DayLeave
{
private:
    std::string date;
    std::vector<OneLeave> leaves; //array
public:
    DayLeave();
    std::string toJson();
    bool addLeave(const OneLeave  oneleave);
    bool removeLeave(const int & index);
    int count();
    std::string getDateStr();
    OneLeave getLeave(const int & index);
    bool initFromJsonString(const std::string & date,const std::string & jsonStr);
};

#endif // DATAPRE_H
